package hello;

import hello.dao.po.ConfigBean;
import hello.dao.po.User;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@EnableConfigurationProperties({ ConfigBean.class, User.class })
public class HelloController {

	@RequestMapping("/")
	public String index() {
		return "地址 ‘http://localhost:9090/springbootpath/’。开始自己配置 端口、url路径了、~~~。";
	}

	// 以下 为自定义 在 application.yml中的 文本属性
	@Value("${my.name}")
	private String name;
	@Value("${my.age}")
	private int age;

	//http://localhost:9090/springbootpath/fileAboutMyInfo
	//显示结果 lixinlei:28
	@RequestMapping("/fileAboutMyInfo")
	public String fileAboutMyInfo() {
		return name + ":" + age;
	}

	@Autowired
	ConfigBean configBean;

	@RequestMapping(value = "/lixinlei")
	public String miya() {
		return configBean.getGreeting() + " |" + configBean.getName() + " |" + configBean.getUuid() + " |"
				+ configBean.getMax();
	}

	@Autowired
	User user;

	@RequestMapping(value = "/user")
	public String user() {
		return user.getName() + user.getAge();
	}
}
